package outputAdapters;

import inputs.Input;

/**
 * Abstract class to encapsulate output behavior.
 * 
 * Bounds the input data into a given Range of output.
 * 
 * Different OutputAdapters can define how they fit the data.
 * 
 * @author Dylan James
 *
 */
public abstract class OutputAdapter extends Input{
	protected Integer value;
	protected Input input;
	protected Range outputRange;
	
	/**
	 * Constructs an OutputAdapter from just a Range.
	 * Protected because we don't have input - this will be covered by
	 * the base class.
	 * 
	 * @param outputType The Range to bind the output to.
	 */
	protected OutputAdapter(Range outputType)
	{
		super();
		this.outputRange = outputType;
		this.outputRange = outputType;
		this.min = outputType.getMin();
		this.max = outputType.getMax();
	}
	
	/**
	 * Constructs an OutputAdapter from a given Range and Input
	 * @param outputType The Range to bind the output to.
	 * @param input The Input to bind.
	 */
	public OutputAdapter(Range outputType, Input input)
	{
		this(outputType);
		this.input = input;		
	}
	
	/**
	 * Constructs an OutputAdapter from a given min, max, and Input.
	 * @param min The minimum value to bind to
	 * @param max The maximum value to bind to.
	 * @param input 
	 */
	public OutputAdapter(Integer min, Integer max, Input input)
	{
		this(new SimpleRange(min, max), input);
	}
	
	/**
	 * @return Returns the Range this OutputAdapter binds to.
	 */
	public Range getOutputType()
	{
		return this.outputRange;
	}
	
	/**
	 * Sets the Range this OutputAdapter binds to
	 * @param range The Range to set it to.
	 */
	public void setOutputType(Range range)
	{
		this.outputRange = range;
	}
	
	/**
	 * @return Returns the Input this OutputAdapter is binding to
	 */
	public Input getInput()
	{
		return this.input;
	}
	
	/**
	 * Sets the Input this OutputAdapter is binding to
	 * @param input
	 */
	public void setInput(Input input)
	{
		this.input = input;
	}
	
	protected abstract void Update();
	
	public final int getValue() {
		return this.value;
	}
}
